# -*-coding:utf-8 -*-
# Author : Mo
# Data : 2022/2/10 10:56
from django.db import models

# Create your models here.
class Admin(models.Model):
    """ 管理员 """
    username = models.CharField(verbose_name="用户名",max_length=32)
    password = models.CharField(verbose_name="密码",max_length=64)

    def __str__(self):
        return self.username


class Teacher(models.Model):
    """ 教师表 """
    name = models.CharField(verbose_name="姓名",max_length=16)
    mobile = models.CharField(verbose_name="手机号", max_length=11)
    # 在Django中做约束
    gender_choices = (
        (1, "男"),
        (2, "女"),
    )
    gender = models.SmallIntegerField(verbose_name="性别", choices=gender_choices)
    age = models.IntegerField(verbose_name="年龄")
    birthday = models.DateField(verbose_name="生日")
    # password = models.CharField(verbose_name="密码", max_length=64)


class Student(models.Model):
    """ 学生表 """
    name = models.CharField(verbose_name="姓名",max_length=16)
    mobile = models.CharField(verbose_name="家长电话", max_length=11)
    # 在Django中做约束
    gender_choices = (
        (1, "男"),
        (2, "女"),
    )
    gender = models.SmallIntegerField(verbose_name="性别", choices=gender_choices)
    start_school = models.DateField(verbose_name="入学日期")
    age = models.IntegerField(verbose_name="年龄")
    # 置空
    headmaster = models.ForeignKey(to="Teacher", to_fields="id", null=True, blank=True, on_delete=models.SET_NULL)

class Achievement(models.Model):
    """ 成绩表 """
    chinese = models.IntegerField(verbose_name="语文")
    math = models.IntegerField(verbose_name="数学")
    english = models.IntegerField(verbose_name="英语")
    student_achievement = models.ForeignKey(to="Student", to_fields="id", on_delete=models.CASCADE)